<{include file="Public/top.html" }>
<link rel="stylesheet" href="Public/Admin/css/calglobal.css?v=8" />
<style>
    .ui-table th, .ui-table td{white-space: inherit;}
</style>
	</head>
	<body>
		<div id="warpper">
            <div class="content">
                <div class="location">预约管理</div>
                <{include file="./nav.html" }>
                <div class="filedSet" style="padding-bottom: 0;">
                    <div class="search">
                        <form action="" id="searchForm" method="get" class="ui-form reportForm">
                            <input name="m" type="hidden" value="<{$module}>">
                            <input name="c" type="hidden" value="<{$controller}>">
                            <input name="a" type="hidden" value="orderList">
                            <input name="id" type="hidden" value="<{$id}>">

                            <input name="p" id="page" type="hidden" value="<{$page|default:1}>">
                            <input name="limit" id="limit" type="hidden" value="<{$limit|default:10}>">


                            <div class="ui-form-item inline-block">
                                <label class="ui-label">开始时间</label>
                                <input id="beginShowTime" name="beginShowTime" readonly class="ui-select" value='<{$beginShowTime}>' type="text" />
                            </div>
                            <div class="ui-form-item inline-block">
                                <label class="ui-label">结束时间</label>
                                <input id="endShowTime" name="endShowTime" readonly class="ui-select" value='<{$endShowTime}>' type="text" />
                            </div>
                            <div class="ui-form-item inline-block">
                                <label class="ui-label">手机号</label>
                                <input type="text" value="<{$phone}>" class="ui-text bg-text keyword" name="phone" placeholder="手机号" style="width: 80px;" />
                            </div>
                            <div class="ui-form-item inline-block">
                                <label class="ui-label">昵称</label>
                                <input type="text" value="<{$nickname}>" class="ui-text bg-text keyword" name="nickname" placeholder="昵称" style="width: 80px;" />
                            </div>

                            <div class="ui-form-item inline-block">
                                <label class="ui-label">项目</label>
                                <select name="item" class="ui-select" >
                                    <option value="0">选择项目</option>
                                    <{html_options options=$itemKv selected=$item}>
                                </select>

                            </div>
                            <div class="ui-form-item inline-block">
                                <label class="ui-label">状态</label>
                                <select name="status" class="ui-select" >
                                    <option value="0">选择状态</option>
                                    <{html_options options=$statusKv selected=$status}>
                                </select>
                            </div>


                            <div class="ui-form-item inline-block">
                                <button type="submit" class="ui-button" onclick="LayerShow();">搜索</button>
                                <button type="button" onclick="exportData();" class="ui-button">导出</button>
                            </div>
                        </form>

                    </div>
                </div>


                <!--表格内容-->
                <div class="mainGrid">
                    <table class="ui-table ui-body">
                        <thead>
                        <tr>
                            <th >订单时间</th>
                            <th >手机号码</th>
                            <th >昵称</th>
                            <th >预约时间</th>
                            <th >项目</th>
                            <th >项目详情</th>
                            <th >预估价格</th>
                            <th >状态</th>
                            <th >地址</th>
                            <th >评分</th>
                            <th >评价</th>
                            <th class="pct10 last-col">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <{foreach from=$list item=item}>
                        <tr >
                            <td><{$item['addTime']|date_format:"%Y-%m-%d <br/> %H:%M:%S"}></td>
                            <td><{$item['phoneNumber']}></td>
                            <td><{$item['nickname']}></td>
                            <td id="dt_<{$item.id}>"><{$item['orderTime']}></td>
                            <td><{$item['itemName']}></td>
                            <td><{$item['itemDetail']}></td>
                            <td><{$item['price']}></td>
                            <td class="s_<{$item.id}>"><{$statusKv[$item['status']]}></td>
                            <td><{$item['area']}><br /><{$item['address']}></td>
                            <td><{$item['score']}></td>
                            <td><{$item['comment']}></td>
                            <td class="ta_l">
                                <div class="handler c_<{$item.id}>">
                                        <{if $item.status eq $IS_FINISH}>
                                            <!--<a href="javascript:cancel('<{$item.id}>');">取消</a>-->
                                            <!--<a href="javascript:assign('<{$item.id}>');">派单</a>-->
                                        <{/if}>
                                        <{if $item.status eq $IS_CANCEL}>
                                            <!--<a href="javascript:assign('<{$item.id}>');">派单</a>-->
                                            <!--<a href="javascript:finish('<{$item.id}>');">完成</a>-->
                                        <{/if}>
                                        <{if $item.status eq $IS_ASSIGN}>
                                            <a href="javascript:cancel('<{$item.id}>');">取消</a>
                                            <a href="javascript:finish('<{$item.id}>');">完成</a>
                                            <a href="javascript:edit('<{$item.id}>','<{$item.itemId}>');">修改</a>
                                        <{/if}>
                                        <{if $item.status eq $IS_INIT}>
                                            <a href="javascript:cancel('<{$item.id}>');">取消</a>
                                            <a href="javascript:assign('<{$item.id}>');">派单</a>
                                            <a href="javascript:finish('<{$item.id}>');">完成</a>
                                            <a href="javascript:edit('<{$item.id}>','<{$item.itemId}>');">修改</a>
                                        <{/if}>
                                </div>
                            </td>
                        </tr>
                        <{/foreach}>
                        </tbody>
                    </table>
                </div>
                <!--作业详情-->
                <div id="task">
                    <!--详情-->
                    <div id="check">

                    </div>
                </div>

                <div class="pagination">
                    <!--描述：分页-->
                    <{include file="Public/page.html" }>
                </div>
            </div>
		</div>
        <div id="editTime" style="display: none;margin-top:10px">

            <div class="ui-form-item">
                <label class="ui-label">当前预约时间</label>
                <input id="oldOrderTime"  readonly class="ui-text" type="text" style="width: 12rem"/>
            </div>
            <input id="newOrderTime"   type="hidden" />
            <!-----------时间选择开始------->

            <div class="time-area" ><!--时间选择表格-->
                <input type="hidden" name="date_" value="">
                <input type="hidden" name="time_">
                <div class="box-date">
                    <ul class="promptu-menu2 font13"></ul>
                </div>
                <div class="time-choose-table font13 txt-gray" id="time-choose-table"></div>
                <div class="font11 txt-light-gray txt-small" style="display:none"> 提示：灰色时间不可选择，最长可预约7天内的服务时间。</div>

                <input type="button" id="submit" value="确定选择" class="am-btn btn-default am-btn-green mt-line btn-choose-time" style='width:94.668%;margin-top:40px;font-size: 16px;'>
            </div>
            <!-----------时间选择结束------->

        </div>
        <{include file="Public/foot.html" }>

        <script src="Public/Admin/js/jquery.promptu-menu.js"></script>
        <script>
            var checkTimeUrl="<{U("wap/HouseWork/getDailyStatus")}>";
            $(function(){
                var type_ = 'hour';
                var days = 5;//可预约天数，含今天

                var nowDateArray = getNowFormatDate().split(' ');
                var date_ = nowDateArray[0];
                t(date_, type_, days);
                $('#submit').click(function() {
                    if (!$('input[name=time_]').val()) {
                        return alert('请选择服务时间');
                    }
                    var textTime = $('input[name=time_]').val().split(':');
                    $('#newOrderTime').val($('input[name=date_]').val() + ' ' + textTime[0] + ':' + textTime[1]);
                    sumbit();
                });

                //////////////////////////////////////////////////////////////////////


            });
        </script>
	</body>
</html>
<script>



    datePickter('beginShowTime','endShowTime',true);
    function baseAction(id,act){
        $.get("<{U('changeStatus')}>"+"&id="+id+"&act="+act,function(data){
            if(data.status==0) {
                $(".c_"+id).html(data.html);
                $(".s_"+id).html(data.statusName);

            }else{
                layer.msg(data.msg);
            }
        },'json');
    }

    function finish(id){
        if(!window.confirm("完成订单操作请在确认用户已经支付后执行？确定后用户将收到通知短信")){return false;}
        baseAction(id,'finish');
    }

    function cancel(id){
        if(!window.confirm("确定取消订单吗？确定后用户将收到通知短信,并且退还其所扣积分")){return false;}
        baseAction(id,'cancel');
    }
    function assign(id){

        baseAction(id,'assign');
    }

   function sumbit(){
        if (sid==0){
                layer.msg("请选定对象");
                return;
            }
        var newTime=$('#newOrderTime').val().trim();
        if (newTime==''){
            layer.msg("请指定新预约时间");
            return;
        }
        if(!window.confirm("确认提交修改吗？提交后用户将收到通知短信")){return false;}
        $.get("<{U('changeTime')}>"+"&id="+sid+"&time="+newTime,function(data){
            if(data.status==0) {
                layer.closeAll();
                $('#dt_'+sid).html(newTime)
            }else{
                layer.msg(data.msg);
            }
        },'json');
    }

    var sid=0;
    var itemId=0;
    function edit(id,iid){
        sid=id;
        itemId=iid;
        $('.promptu-menu2 li').get(0).click();
        $('#oldOrderTime').val($('#dt_'+id).html());
        layer.open({
            type: 1,
            title: "修改预约时间",
            closeBtn: 1,
            area:['600px','500px'],
            shadeClose: false,
            content: $('#editTime')
        });
    }




    //名单导出
    function exportData(){
        if($("#searchForm select[name='eid']").val() == 0){
            layer.msg('请针对单个活动导出！');
            return false;
        }
        window.location.href = "<{u('orderList')}>"+'&export=1&'+$('#searchForm').serialize()

    }


</script>
